package net.oschina.dajiangnan.tree;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.LinkedList;
import java.util.List;

/**
 * 流程上下文,即流程中各节点的传参
 */
@Data
public abstract class AbstractContext {

    @Data
    @AllArgsConstructor
    public static class TraceInfo {
        private Class nodeClass;
        private Long last;
    }

    private List<TraceInfo> nodeTrace = new LinkedList<>();

    public String traceInfo() {
        StringBuilder sb = new StringBuilder();
        nodeTrace.forEach(t -> {
            sb.append(t.nodeClass.getSimpleName() + "->");
        });
        nodeTrace.forEach(t -> {
            sb.append(t.last + ",");
        });
        return sb.toString();
    }
}
